package cn.embeddedKey.method1;

import lombok.Data;

import java.io.Serializable;

/**
 * 主键类 UserEntityPk
 * <p>
 * 主键类需要满足以下要求(否则各种报错)
 * 1. 实现 Serializable 接口
 * 2. 有public无参构造方法
 * 3. 覆盖equals和hashCode方法(eclipse和IDEA中均可自动生成)
 *
 * @Data 注解补充：点进去后看官方解释，如下
 * Generates getters for all fields, a useful toString method, and hashCode and equals implementations that check
 * all non-transient fields. Will also generate setters for all non-final fields, as well as a constructor.
 * Equivalent to {@code @Getter @Setter @RequiredArgsConstructor @ToString @EqualsAndHashCode}.
 * 即 @Data 等价于这五个注解 @Getter @Setter @RequiredArgsConstructor @ToString @EqualsAndHashCode
 */
@Data
public class UserEntityID implements Serializable {
    private String userName;
    private String userPhone;

//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        UserEntityPk that = (UserEntityPk) o;
//        return Objects.equals(userName, that.userName) && Objects.equals(userPhone, that.userPhone);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(userName, userPhone);
//    }
}
